// 消费Redis队列中的任务，进行转码操作
import { Process, Processor } from '@nestjs/bull';
import { Inject } from '@nestjs/common';
import { Logger } from 'src/common/logger/logger';
import bull from 'bull';

/**
 * processor：队列处理器
 * 1、处理队列中的任务
 * 2、根据任务类型，调用不同的处理方法
 */
@Processor('queue')
export class QueueProcessor {
  @Inject()
  private readonly logger: Logger;

  @Process('transcode')
  handleTranscode(job: bull.Job) {
    this.logger.info('Start transcoding...');
    this.logger.info('job.data==>', job.data);
    this.logger.info('Transcoding completed');
  }
}
